﻿using log4net;
using log4net.Config;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace Himp.Platform.Client
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        private static SampleCodeGenerateWorker sampleCodeGenerateWorker;
        private static readonly ILog log = LogManager.GetLogger(typeof(App));


        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            // 配置 Log4net
            XmlConfigurator.Configure();

            Task.Factory.StartNew(async () =>
            {
                while (true)
                {
                    try
                    {
                        await Task.Delay(60000);
                        var sampleCodeGenerateWorker = new SampleCodeGenerateWorker();
                        await sampleCodeGenerateWorker.StartAsync(new System.Threading.CancellationToken());
                    }
                    catch (Exception ee)
                    {
                        log.Error(ee.Message, ee);
                    }
                }
            });
        }
    }
}
